package yourobot.config;

import java.util.ArrayList;
import java.util.HashMap;

import fr.umlv.zen.KeyboardKey;

/**
 * 
 * @author mehdimasrour
 *
 */
public class KeyConfig {

	private final ArrayList<KeyboardKey> keylist;
	private final HashMap<KeyboardKey, String> direction;
	
	/**
	 * 
	 * @param player id of the player (1 or 2 atm)
	 */
	public KeyConfig(int player){
		keylist = new ArrayList<>();
		direction = new HashMap<>();
		switch (player){
			case 1:
				keylist.add(KeyboardKey.UP);
				direction.put(KeyboardKey.UP, "up");
				keylist.add(KeyboardKey.DOWN);
				direction.put(KeyboardKey.DOWN, "down");
				keylist.add(KeyboardKey.LEFT);
				direction.put(KeyboardKey.LEFT, "left");
				keylist.add(KeyboardKey.RIGHT);
				direction.put(KeyboardKey.RIGHT, "right");
				break;
			case 2:
				keylist.add(KeyboardKey.Z);
				direction.put(KeyboardKey.Z, "up");
				keylist.add(KeyboardKey.S);
				direction.put(KeyboardKey.S, "down");
				keylist.add(KeyboardKey.Q);
				direction.put(KeyboardKey.Q, "left");
				keylist.add(KeyboardKey.D);
				direction.put(KeyboardKey.D, "right");
		}
	}
	
	/**
	 * 
	 * @param k KeyBoardKey to test
	 * @return true if the key pressed is in the player's config
	 */
	public boolean validKey(KeyboardKey k){
		return keylist.contains(k);
	}
	
	/**
	 * 
	 * @param k KeyboardKey to test
	 * @return a string corresponding to the "direction"
	 */
	public String getDirection(KeyboardKey k){
		return direction.get(k);
	}

	
}
